package com.yssystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.yssystem.domain.SysUser;
import com.yssystem.mapper.SysUserMapper;
import com.yssystem.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
* @author Administrator
* @description 针对表【sys_user(用户表)】的数据库操作Service实现
* @createDate 2024-07-11 15:30:20
*/
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
    implements SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public List<SysUser> getUserList(String keyName, String postValue, String roleValue) {
//        System.out.println(sysUserMapper.getUserList());
        System.out.println(keyName+postValue+roleValue+"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        List<SysUser> userList = sysUserMapper.getUserList(keyName, postValue, roleValue);
        List<SysUser> sysUsers = new ArrayList<>();
        for (SysUser e: userList
             ) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            // 将日期对象转换为指定格式的字符串
            String formattedDate = sdf.format(e.getCreateTime());
            e.setTime(formattedDate);
            sysUsers.add(e);
        }

        return sysUsers ;

    }

    @Override
    public Boolean updateStatus(Integer status, Integer id) {
        Boolean aBoolean = sysUserMapper.updateStatus(status, id);
        return aBoolean;
    }

    @Override
    public Boolean delUser(Integer id) {
        Boolean aBoolean = sysUserMapper.delUser(id);
        return aBoolean;
    }
}




